package LeetCode;

import java.util.Arrays;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}17:40
 */
public class LeetCode300 {

    public static void main(String[] args) {
        int[] arr = {10,9,2,5,3,7,101,18};
        System.out.println(new LeetCode300().lengthOfLIS(arr));
    }

    public int lengthOfLIS(int[] nums){
       //递归的形式 动态规划
        if (nums.length == 0){
            return 0;
        }
        int[] dp = new int[nums.length];
        Arrays.fill(dp,1);
        for (int i = 1; i < nums.length; i++){
            for (int j = 0; j < i; j++){
                if (nums[i] > nums[j]){
                    dp[i] = Math.max(dp[i],1 + dp[j]);
                }
            }
        }
        Arrays.sort(dp);
        return dp[nums.length - 1];
    }
}
